package com.third.customer.site.controller.resp;

import com.third.customer.model.tables.CustomerGroup;
import com.third.customer.service.utils.TimeUtils;
import lombok.Data;

/**
 * Created by hehuaichun on 2020/6/27.
 */
@Data
public class CustomerGroupResp {

    private String id;

    private String companyId;

    private String name;

    private String description;

    private String updatedAt;

    private String createdAt;

    public static CustomerGroupResp convert(CustomerGroup group){
        CustomerGroupResp resp = new CustomerGroupResp();
        resp.setId(String.valueOf(group.getId()));
        resp.setCompanyId(String.valueOf(group.getCompanyId()));
        resp.setName(group.getName());
        resp.setDescription(group.getDescription());
        if(group.getCreatedAt()!=null){
            resp.setCreatedAt(TimeUtils.dateToString(group.getCreatedAt()));
        }
        if(group.getUpdatedAt()!= null){
            resp.setUpdatedAt(TimeUtils.dateToString(group.getUpdatedAt()));
        }
        return resp;
    }
}
